import 'package:flutter/material.dart';
import 'package:music_app/widget/my_cached_network_image.dart';

class SongItem extends StatelessWidget {
  final String imageUrl;
  final String title;
  final String artist;
  final VoidCallback? onTap;

  const SongItem({
    super.key,
    required this.imageUrl,
    required this.title,
    required this.artist,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return InkWell(
      excludeFromSemantics: true,
      onTap: onTap,
      child: Padding(
        padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
        child: Row(
          children: [
            ClipRRect(
              borderRadius: BorderRadius.circular(8),
              child: MyCachedNetworkImage(
                imageUrl: imageUrl,
                width: 40,
                height: 40,
                x: 160,
                y: 160,
              ),
            ),
            const SizedBox(width: 12),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    title,
                    style: const TextStyle(
                        fontSize: 16, fontWeight: FontWeight.bold),
                    overflow: TextOverflow.ellipsis,
                  ),
                  const SizedBox(height: 4),
                  Text(
                    artist,
                    style: TextStyle(
                      fontSize: 14,
                      color: Colors.grey.shade600,
                    ),
                    overflow: TextOverflow.ellipsis,
                  ),
                ],
              ),
            ),
            IconButton(
              onPressed: onTap,
              icon: const Icon(Icons.play_arrow, size: 16, color: Colors.black),
            ),
          ],
        ),
      ),
    );
  }
}
